package com.java.multipledatasource.thread;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author hu
 * @version 1.0
 * @date 2021/1/18 0018 上午 8:31
 * @description 线程池 ThreadPoolExecutor  ForkJoinPool
 */
public class ThreadPool {
    public static void main(String[] args) {
        /**
         * 核心线程数
         * 最大线程数
         * 存活时间
         * 存活单位
         * 任务队列
         * 生成线程工厂
         * 拒绝策略
         */
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(2, 4,
                60, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(100),
                Executors.defaultThreadFactory(), new ThreadPoolExecutor.DiscardOldestPolicy());
        threadPoolExecutor.execute(() -> System.out.println("hello"));
        threadPoolExecutor.submit(() -> System.out.println("111"));

    }
}
